package com.liuscraft.tradingplatform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuscraft.tradingplatform.entity.GoodPriceHistory;
import com.liuscraft.tradingplatform.service.IGoodPriceHistoryService;
import com.liuscraft.tradingplatform.mapper.GoodPriceHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author Lenovo
* @description 针对表【good_price_history(价格历史)】的数据库操作Service实现
* @createDate 2024-04-20 14:15:27
*/
@Service
public class IGoodPriceHistoryServiceImpl extends ServiceImpl<GoodPriceHistoryMapper, GoodPriceHistory> implements IGoodPriceHistoryService {

    @Autowired
    private GoodPriceHistoryMapper goodPriceHistoryMapper;

    @Override
    public List<GoodPriceHistory> getGoodPriceHistory(GoodPriceHistory goodPriceHistory) {
        LambdaQueryWrapper<GoodPriceHistory> queryWrapper = new LambdaQueryWrapper<GoodPriceHistory>();
        queryWrapper.eq(GoodPriceHistory::getGoodId,goodPriceHistory.getGoodId());
        queryWrapper.orderByDesc(GoodPriceHistory::getCreateDate);
        List<GoodPriceHistory> goodPriceHistories = goodPriceHistoryMapper.selectList(queryWrapper);
        return goodPriceHistories;
    }

    @Override
    public int addGoodPriceHistory(GoodPriceHistory goodPriceHistory) {
        return goodPriceHistoryMapper.insert(goodPriceHistory);
    }
}




